package response

import (
	"github.com/minio/minio-go/v7"
	"time"
)

type GetObjectsResp struct {
	Response
	ObjectInfo []minio.ObjectInfo `json:"ObjectInfo"`
}

//	type ObjectData struct {
//		Type     constanct.DataType `json:"Type"`
//		FileName string             `json:"Filename"`
//		Data     []FileData         `json:"Data"`
//		Body     []byte             `json:"Body"`
//	}

type GetBucketsResp struct {
	Response
	Buckets []minio.BucketInfo `json:"Buckets"`
}

type GetBucketStatsResp struct {
	Response
	Found   bool   `json:"Found"`
}
type GetBucketPolicyResp struct{
	Response
	Policy string `json:"Policy"`
}
type GetObjectResp struct {
	Response
	ObjectData string `json:"ObjectData"`
}
type PutObjectResp struct {
	Response
	UpInfo minio.UploadInfo `json:"UpInfo"`
}
type GetPresignedObjectResp struct {
	Response
	PresignedUrl string `json:"PresignedUrl"`
}
type FPutObjectResp struct {
	Response
	UpInfo minio.UploadInfo `json:"UpInfo"`
}

// type CreateObjectResp struct {
// 	Response
// 	UpInfo minio.UploadInfo `json:"UpInfo"`
// }

type GetObjectInfoResp struct {
	Response
	ObjectInfo minio.ObjectInfo `json:"ObjectInfo"`
}

type BucketInfo struct {
	// The name of the bucket.
	Name string `json:"name"`
	// Date the bucket was created.
	CreationDate time.Time `json:"creationDate"`
}
type UploadInfo struct {
	Bucket       string
	Key          string
	ETag         string
	Size         int64
	LastModified time.Time
	Location     string
	VersionID    string

	// Lifecycle expiry-date and ruleID associated with the expiry
	// not to be confused with `Expires` HTTP header.
	Expiration       time.Time
	ExpirationRuleID string

	// Verified checksum values, if any.
	// Values are base64 (standard) encoded.
	// For multipart objects this is a checksum of the checksum of each part.
	ChecksumCRC32  string
	ChecksumCRC32C string
	ChecksumSHA1   string
	ChecksumSHA256 string
}

type ObjectInfo struct {
	// An ETag is optionally set to md5sum of an object.  In case of multipart objects,
	// ETag is of the form MD5SUM-N where MD5SUM is md5sum of all individual md5sums of
	// each parts concatenated into one string.
	ETag string `json:"etag"`

	Key          string    `json:"name"`         // Name of the object
	LastModified time.Time `json:"lastModified"` // Date and time the object was last modified.
	Size         int64     `json:"size"`         // Size in bytes of the object.
	ContentType  string    `json:"contentType"`  // A standard MIME type describing the format of the object data.
	Expires      time.Time `json:"expires"`      // The date and time at which the object is no longer able to be cached.

	// Collection of additional metadata on the object.
	// eg: x-amz-meta-*, content-encoding etc.
	Metadata Header `json:"metadata" xml:"-"`

	// x-amz-meta-* headers stripped "x-amz-meta-" prefix containing the first value.
	// Only returned by MinIO servers.
	UserMetadata StringMap `json:"userMetadata,omitempty"`

	// x-amz-tagging values in their k/v values.
	// Only returned by MinIO servers.
	UserTags URLMap `json:"userTags,omitempty" xml:"UserTags"`

	// x-amz-tagging-count value
	UserTagCount int

	// Owner name.
	Owner Owner

	// ACL grant.
	Grant []Grant

	// The class of storage used to store the object.
	StorageClass string `json:"storageClass"`

	// Versioning related information
	IsLatest       bool
	IsDeleteMarker bool
	VersionID      string `xml:"VersionId"`

	// x-amz-replication-status value is either in one of the following states
	// - COMPLETED
	// - PENDING
	// - FAILED
	// - REPLICA (on the destination)
	ReplicationStatus string `xml:"ReplicationStatus"`
	// set to true if delete marker has backing object version on target, and eligible to replicate
	ReplicationReady bool
	// Lifecycle expiry-date and ruleID associated with the expiry
	// not to be confused with `Expires` HTTP header.
	Expiration       time.Time
	ExpirationRuleID string

	Restore *RestoreInfo

	// Checksum values
	ChecksumCRC32  string
	ChecksumCRC32C string
	ChecksumSHA1   string
	ChecksumSHA256 string

	Internal *struct {
		K int // Data blocks
		M int // Parity blocks
	} `xml:"Internal"`

	// Error
	Err error `json:"-"`
}
type RestoreInfo struct {
	// Is the restoring operation is still ongoing
	OngoingRestore bool
	// When the restored copy of the archived object will be removed
	ExpiryTime time.Time
}
type Grantee struct {
	XMLName     Name   `xml:"Grantee"`
	ID          string `xml:"ID"`
	DisplayName string `xml:"DisplayName"`
	URI         string `xml:"URI"`
}
type Grant struct {
	XMLName    Name `xml:"Grant"`
	Grantee    Grantee
	Permission string `xml:"Permission"`
}
type Owner struct {
	XMLName     Name   `xml:"Owner" json:"owner"`
	DisplayName string `xml:"ID" json:"name"`
	ID          string `xml:"DisplayName" json:"id"`
}
type URLMap map[string]string
type StringMap map[string]string
type Header map[string][]string
type Name struct {
	Space, Local string
}
